package com.jniproject;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

/**
 *
 *  //JNI返回Java对象(转)  https://www.cnblogs.com/yongdaimi/p/14023154.html
 */
public class StructActivity extends AppCompatActivity {
    private static final String TAG = "StructActivity";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_struct);
    }

    public void newBookJni(View view) {
        Log.i(TAG, "newBookJni: ");
        long l = newBookJni();
        Log.i(TAG, "newBookJni: result: "+l);
    }

    //JNI返回Java对象(转)  https://www.cnblogs.com/yongdaimi/p/14023154.html
    public void bookJniToJava(View view) {
        Log.i(TAG, "bookJniToJava: stat:");
        BookJava book = getBook();
        Log.i(TAG, "bookJniToJava: result: "+book.toString());
    }

    public void inputObjGetLong(View view) {
        long l = newBookJni1(new BookJava());
        Log.i(TAG, "inputObjGetLong: "+l);
    }




    static {
        System.loadLibrary("native-lib-sturct");
    }

    //descriptor: (Lcom/jniproject/BookJava;)J
    public static native long newBookJni1(BookJava book);

    //descriptor: ()J
    public static native long newBookJni();

    //descriptor: ()Lcom/jniproject/BookJava;
    public static native BookJava getBook();
}